home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / 3rdparty / tools / toolcrft / demo / demo003.clw < prev    next >
Encoding:
Text File  |  1995-10-23  |  76.7 KB  |  1,085 lines

  1.                      MEMBER('DEMO.clw')                         ! This is a MEMBER module
  2.                      MAP
  3.                        BrowseIntermediate:Update:BrowseQueue2(LONG,LONG,<LONG>,<BYTE>,<BYTE>)
  4.                      END
  5.  
  6.  
  7.  
  8.  
  9. BrowseIntermediate   PROCEDURE
  10.  
  11. !--------------------------------------------------------------------------------------------------!
  12. ! Declarations                                                                                     !
  13. !--------------------------------------------------------------------------------------------------!
  14. LocalRequest         LONG,AUTO
  15. LocalResponse        LONG,AUTO
  16. WindowOpened         LONG
  17. Search               STRING(40)
  18. ChangeOrder          STRING(1)
  19. MarkStatus           STRING(15)
  20. Search2              STRING(20)
  21. OriginalRequest      LONG,AUTO
  22. WindowInitialized    LONG
  23. ForceRefresh         LONG,AUTO
  24. WinWidth             LONG(359)                                  ! Save Window Width for Resizing
  25. WinHeight            LONG(178)                                  ! Save Window Height for Resizing
  26. CurrentSelected      LONG,AUTO                                  ! Save Current Selected Field
  27.  
  28. FORMAT:BrowseQueue1:Default EQUATE('60L(1)|_~MarkStatus~@s15@85L(1)|_~Name~@S20@20L(1)|_~Code~@S5@')
  29.  
  30. SQ1:SortOrder        BYTE                                       !Current Sort Order for the List Box
  31. DropBoxOrderQ        QUEUE,PRE(SQ1)                             !Queue Use to Store Sort Order Info
  32. OrderName              STRING(60)                               !  Description shown in drop box
  33. SearchPicture          STRING(30)                               !  Picture Clause for Search Field
  34. OrderFormat            STRING(500)                              !  Format String for the List Box
  35.                      END                                        !End Queue Declaration
  36.  
  37. FORMAT:BrowseQueue2:Default EQUATE('')
  38. FORMAT:BrowseQueue2:Order1 EQUATE('60L(1)|_~Ingredient~@S15@32L(1)|_~Measure~@S8@20L(1)|_~Qty~@S5@')
  39. FORMAT:BrowseQueue2:Order2 EQUATE('32L(1)|_~Measure~@S8@#2#20L(1)|_~Qty~@S5@60L(1)|_~Ingredient~@S15@#1#')
  40.  
  41. SQ7:SortOrder        BYTE                                       !Current Sort Order for the List Box
  42. OptBoxOrderQ:BrowseQueue2 QUEUE,PRE(SQ7)                        !Queue Use to Store Sort Order Info
  43. OrderName              STRING(60)                               !  Description shown in drop box
  44. SearchPicture          STRING(30)                               !  Picture Clause for Search Field
  45. OrderFormat            STRING(500)                              !  Format String for the List Box
  46.                      END                                        !End Queue Declaration
  47.  
  48. MarkAllFlag          BYTE                                       !Flag Indicating All Records Marked
  49. MarkQueue            QUEUE,PRE(MQ1)                             !Queue Used to Store Marked Records
  50. RecipeNo               LIKE(RCP:RecipeNo),NAME('TC_MarkKey')    !  Unique Record Id for the File
  51.                      END                                        !End Queue Declaration
  52.  
  53.  
  54. BrowseQueue1         QUEUE                                      !Queue Used by List when Browsing Records
  55. MarkStatus             LIKE(MarkStatus)                         !  Queue Display Field
  56. RCP:Name               LIKE(RCP:Name)                           !  Queue Display Field
  57. RCP:Code               LIKE(RCP:Code)                           !  Queue Display Field
  58. RCP:RecipeNo           LIKE(RCP:RecipeNo)                       !  Queue Display Field
  59. Position               STRING(255)                              !  Queue POSITION Information
  60.                      END                                        !End Queue Declaration
  61.  
  62. BrowseQueue2         QUEUE                                      !Queue Used by List when Browsing Records
  63. ING:Ingredient         LIKE(ING:Ingredient)                     !  Queue Display Field
  64. ING:Measure            LIKE(ING:Measure)                        !  Queue Display Field
  65. ING:Quantity           LIKE(ING:Quantity)                       !  Queue Display Field
  66. Position               STRING(255)                              !  Queue POSITION Information
  67.                      END                                        !End Queue Declaration
  68. LocLen:BrowseQueue2  BYTE
  69.  
  70.  
  71. Screen               WINDOW('Intermediate Browse Exercise'),AT(,,359,178),FONT('MS Sans Serif',8,,),CENTER,STATUS,SYSTEM,GRAY,MAX,RESIZE,MASK,MDI,IMM
  72.                        LIST,AT(5,34,207,73),MSG('Browsing Records'),ALRT(CtrlEnter),ALRT(InsertKey),ALRT(DeleteKey),USE(?List1),IMM,HVSCROLL,VCR,FORMAT(FORMAT:BrowseQueue1:Default),FROM(BrowseQueue1)
  73.                        LIST,AT(221,34,133,73),MSG('Browsing Records'),ALRT(CtrlEnter),ALRT(InsertKey),ALRT(DeleteKey),USE(?List2),IMM,NOBAR,VSCROLL,FROM(BrowseQueue2),FORMAT(FORMAT:BrowseQueue2:Default)
  74.                        BUTTON('&Mark'),AT(23,109,40,10),USE(?Mark)
  75.                        BUTTON('&Unmark'),AT(65,109,40,10),USE(?Unmark)
  76.                        BUTTON('Mark &All'),AT(107,109,40,10),USE(?MarkAll)
  77.                        BUTTON('&Clear All'),AT(149,109,40,10),USE(?UnmarkAll)
  78.                        PROMPT('Sort By:'),AT(3,4,28,10),USE(?ChangeOrder:Prompt)
  79.                        LIST,AT(32,4,80,10),USE(?ChangeOrder),FORMAT('160L@s40@'),DROP(4),FROM(DropBoxOrderQ)
  80.                        OPTION,AT(221,3,90,17),USE(?ChangeOrder2)
  81.                          RADIO('Ingredient'),AT(224,9),USE(?ChangeOrder2:Radio1)
  82.                          RADIO('Measure'),AT(270,9),USE(?ChangeOrder2:Radio2)
  83.                        END
  84.                        BUTTON('Close'),AT(314,165,40,10),USE(?Close)
  85.                        PROMPT('Search:'),AT(5,17,25,10),USE(?Search:Prompt)
  86.                        ENTRY(@S40),AT(32,17,80,10),MSG('Enter Search Criteria'),USE(Search)
  87.                        PROMPT('Search:'),AT(223,22,25,10),USE(?Search:Prompt:1)
  88.                        ENTRY(@S40),AT(251,22,68,10),MSG('Enter Search Criteria'),USE(Search2)
  89.                        BUTTON('Insert'),AT(234,151,40,10),USE(?Insert)
  90.                        BUTTON('Change'),AT(274,151,40,10),USE(?Change)
  91.                        BUTTON('Delete'),AT(314,151,40,10),USE(?Delete)
  92.                        PROMPT('&Recipe#:'),AT(13,126),USE(?RCP:RecipeNo:Prompt)
  93.                        PROMPT('&Recipe#:'),AT(233,111),USE(?ING:RecipeNo:Prompt)
  94.                        ENTRY(@N_5),AT(267,110),USE(ING:RecipeNo),READONLY
  95.                        ENTRY(@N_5),AT(47,125),USE(RCP:RecipeNo),READONLY
  96.                        PROMPT('&Name:'),AT(20,141),USE(?RCP:Name:Prompt)
  97.                        PROMPT('&Ingredient:'),AT(227,126),USE(?ING:Ingredient:Prompt)
  98.                        ENTRY(@S15),AT(267,124),USE(ING:Ingredient),READONLY
  99.                        ENTRY(@S20),AT(47,140),USE(RCP:Name),READONLY
  100.                      END
  101.  
  102.  
  103. !--------------------------------------------------------------------------------------------------!
  104. ! Code Section                                                                                     !
  105. !--------------------------------------------------------------------------------------------------!
  106.   CODE
  107.  
  108.   LocalRequest = GlobalRequest
  109.   OriginalRequest = LocalRequest
  110.   LocalResponse = RequestCancelled
  111.   ForceRefresh = False
  112.   CLEAR(GlobalRequest)
  113.   CLEAR(GlobalResponse)
  114.  
  115.   IF INGREDIENT::Used = 0
  116.     CheckOpen(INGREDIENT,1)
  117.   END
  118.   INGREDIENT::Used += 1
  119.   IF RECIPE::Used = 0
  120.     CheckOpen(RECIPE,1)
  121.   END
  122.   RECIPE::Used += 1
  123.  
  124.   OPEN(Screen)
  125.   WindowOpened = True
  126.   INIRestoreWindow('BrowseIntermediate','PTDEMO.INI')
  127.   DO ResizeWindow                                               !Call Resize Window Routine
  128.   Screen{PROP:Imm} = 1                                          !Allow Resize Events to be Posted
  129.   HIDE(?List1)                                                  !Delay Display of List Box
  130.   HIDE(?List2)                                                  !Delay Display of List Box
  131.   DO LoadSortOrders:BrowseQueue1
  132.   DO LoadSortOrders:BrowseQueue2
  133.   SELECT(?List1)
  134.  
  135.   ?List2{Prop:Alrt,250} = BSKey                                 !Alert BackSpace Key for Incremental Locator
  136.   ?List2{Prop:Alrt,249} = SpaceKey                              !Alert Space Key for Incremental Locator
  137.  
  138.   ACCEPT                                                        !Begin Processing Event Loop
  139.                                                                 !
  140.     IF SELECTED() THEN CurrentSelected = SELECTED().            !Save Current Field Selection
  141.     CASE EVENT()                                                !Process Events for the Window
  142.     OF EVENT:OpenWindow
  143.       IF NOT WindowInitialized
  144.         DO InitializeWindow
  145.         WindowInitialized = True
  146.       END
  147.       SELECT(FIRSTFIELD())
  148.       UNHIDE(?List1)                                            !Unhide Filled List Box
  149.       UNHIDE(?List2)                                            !Unhide Filled List Box
  150.     OF EVENT:GainFocus
  151.       IF NOT WindowInitialized
  152.         WindowInitialized = True
  153.         DO InitializeWindow
  154.       ELSE
  155.         ForceRefresh = True
  156.         DO RefreshWindow
  157.       END
  158.     ELSE
  159.       IF EVENT() = EVENT:Sized                                  !IF Window Was Resized
  160.         DO ResizeWindow                                         !  Call Resize Window Routine
  161.       END                                                       !End If
  162.     END                                                         !End Events for Window
  163.  
  164.     CASE FIELD()                                                !Process Events for Controls
  165.     OF ?List1
  166.       CASE EVENT()                           
  167.       OF EVENT:Locate                 
  168.         SELECT(?Search)                                         !Select Locator Field
  169.       OF EVENT:AlertKey                 
  170.         DO StepSearch:BrowseQueue1
  171.       END
  172.       IF EVENT() <> EVENT:AlertKey AND |                        !If Not an Alert Key or a
  173.          EVENT() <> EVENT:PreAlertKey AND |                     !   Pre-Alert Key Event and
  174.          EVENT() <> EVENT:Selected                              !   Control not reselected
  175.         Search = ''                                             !  Clear the Search Input Field
  176.         DISPLAY(?Search)                                        !  Display Locator Field
  177.       END                                                       !End If
  178.       DO BrowseList:BrowseQueue1                                !Fill Browse Area
  179.     OF ?List2
  180.       CASE EVENT()                           
  181.       OF EVENT:AlertKey                 
  182.         DO StepSearch:BrowseQueue2
  183.         DO IncrementalSearch:BrowseQueue2
  184.       END
  185.       IF EVENT() <> EVENT:AlertKey AND |                        !If Not an Alert Key or a
  186.          EVENT() <> EVENT:PreAlertKey AND |                     !   Pre-Alert Key Event and
  187.          EVENT() <> EVENT:Selected                              !   Control not reselected
  188.         LocLen:BrowseQueue2 = 0                                 !  Clear Locator Length
  189.         Search2 = ''                                            !  Clear the Search Input Field
  190.         DISPLAY(?Search2)                                       !  Display Locator Field
  191.       END                                                       !End If
  192.       DO BrowseList:BrowseQueue2                                !Fill Browse Area
  193.     OF ?Mark                              
  194.       CASE EVENT()                           
  195.       OF EVENT:Accepted                 
  196.         GET(BrowseQueue1,CHOICE(?List1))                        !Reget Current Record ID
  197.         MQ1:RecipeNo = BrowseQueue1:RCP:RecipeNo                !Prepare to Search for Marked Record
  198.         GET(MarkQueue,MQ1:RecipeNo)                             !See if Record is Marked
  199.         IF NOT MarkAllFlag                                      !If Not Marking All Exceptions
  200.           IF ERROR()                                            !  If Record Not Marked
  201.             BrowseQueue1:MarkStatus = 'Marked'                  !    Show Record as Marked in the List Box
  202.             MQ1:RecipeNo = BrowseQueue1:RCP:RecipeNo            !    Set up to Add Record to the Mark Queue
  203.             ADD(MarkQueue,MQ1:RecipeNo)                         !    Add the Record to the Mark Queue
  204.             PUT(BrowseQueue1)                                   !    Update the Changes to the List Box
  205.           END                                                   !  End If
  206.         ELSE                                                    !Otherwise Mark Table is an Exception List
  207.           IF NOT ERROR()                                        !  If Record Not Marked
  208.             BrowseQueue1:MarkStatus = 'Marked'                  !    Show Record as Marked in the List Box
  209.             DELETE(MarkQueue)                                   !    Delete the Record from the Mark Queue
  210.             PUT(BrowseQueue1)                                   !    Update the Changes to the List Box
  211.           END                                                   !  End If
  212.         END                                                     !End If
  213.         SELECT(?List1)                                          !Go Back to List Box After Button Press
  214.       END                                    
  215.     OF ?Unmark                              
  216.       CASE EVENT()                           
  217.       OF EVENT:Accepted                 
  218.         GET(BrowseQueue1,CHOICE(?List1))                        !Reget Current Record ID
  219.         MQ1:RecipeNo = BrowseQueue1:RCP:RecipeNo                !Prepare to Search for Marked Record
  220.         GET(MarkQueue,MQ1:RecipeNo)                             !See if Record is Marked
  221.         IF NOT MarkAllFlag                                      !If Not Marking All Exceptions
  222.           IF NOT ERROR()                                        !  If Record is Marked
  223.             BrowseQueue1:MarkStatus = 'UnMarked'                !    Show Record as Not Marked in the List Box
  224.             DELETE(MarkQueue)                                   !    Delete the Record from the Mark Queue
  225.             PUT(BrowseQueue1)                                   !    Update the Changes to the List Box
  226.           END                                                   !  End If
  227.         ELSE                                                    !Otherwise Mark Table is an Exception List
  228.           IF ERROR()                                            !  If Record is Marked
  229.             BrowseQueue1:MarkStatus = 'UnMarked'                !    Show Record as Not Marked in the List Box
  230.             MQ1:RecipeNo = BrowseQueue1:RCP:RecipeNo            !    Set up to Add Record to the Mark Queue
  231.             ADD(MarkQueue,MQ1:RecipeNo)                         !    Add the Record to the Mark Queue
  232.             PUT(BrowseQueue1)                                   !    Update the Changes to the List Box
  233.           END                                                   !  End If
  234.         END                                                     !End If
  235.         SELECT(?List1)                                          !Go Back to List Box After Button Press
  236.       END                                    
  237.     OF ?MarkAll                              
  238.       CASE EVENT()                           
  239.       OF EVENT:Accepted                 
  240.         MarkAllFlag = 1                                         !Mark Queue is Now an Exception List
  241.         FREE(MarkQueue)                                         !Mark All Records
  242.         LOOP Rec# = 1 TO RECORDS(BrowseQueue1)                  !Loop Through the List Boxes Records
  243.           GET(BrowseQueue1,Rec#)                                !  Read the Queue Record
  244.           BrowseQueue1:MarkStatus = 'Marked'                    !  Show Record as Marked in the List Box
  245.           PUT(BrowseQueue1)                                     !  Update the Changes to the List Box
  246.         END                                                     !End Loop
  247.         SELECT(?List1)                                          !Go Back to List Box After Button Press
  248.       END                                    
  249.     OF ?UnmarkAll                              
  250.       CASE EVENT()                           
  251.       OF EVENT:Accepted                 
  252.         MarkAllFlag = 0                                         !Mark Queue is Now a List of Marked Records
  253.         FREE(MarkQueue)                                         !UnMark All Records
  254.         LOOP Rec# = 1 TO RECORDS(BrowseQueue1)                  !Loop Through the List Boxes Records
  255.           GET(BrowseQueue1,Rec#)                                !  Read the Queue Record
  256.           BrowseQueue1:MarkStatus = 'UnMarked'                  !  Show Record as Not Marked in the List Box
  257.           PUT(BrowseQueue1)                                     !  Update the Changes to the List Box
  258.         END                                                     !End Loop
  259.         SELECT(?List1)                                          !Go Back to List Box After Button Press
  260.       END                                    
  261.     OF ?ChangeOrder                              
  262.       CASE EVENT()                           
  263.       OF EVENT:Accepted                 
  264.         GET(DropBoxOrderQ,CHOICE())                             !Get Order settings from Sort Orders Queue
  265.         IF NOT ERROR()                                          !IF Valid Choice was Selected
  266.           SQ1:SortOrder = CHOICE()                              !  Set sort order
  267.           ?Search{PROP:Text} = SQ1:SearchPicture                !  Set Picture for Search Field
  268.           ?List1{PROP:Format} = SQ1:OrderFormat                 !  Set number of rows in list box
  269.           TC_PROP:BRW(?List1,TCPROP:Rows,?List1{PROP:Items})    !  Reset number of rows property
  270.           TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)    !  Tell Browse to start redisplay with a search by key
  271.           TC_PROP:BRW(?List1,TCPROP:SetToPosition,2)            !  Set Redisplay at Key Position in Queue
  272.           DO BrowseList:BrowseQueue1                            !  Call BrowseList and Execute Redisplay
  273.         END                                                     !End
  274.       END                                    
  275.     OF ?ChangeOrder2                              
  276.       CASE EVENT()                           
  277.       OF EVENT:Accepted                 
  278.         GET(OptBoxOrderQ:BrowseQueue2,CHOICE())                 !Get Order settings from Sort Orders Queue
  279.         IF NOT ERROR()                                          !IF Valid Choice was Selected
  280.           SQ7:SortOrder = CHOICE()                              !  Set sort order
  281.           ?Search2{PROP:Text} = SQ7:SearchPicture               !  Set Picture for Search Field
  282.           ?List2{PROP:Format} = SQ7:OrderFormat                 !  Set number of rows in list box
  283.           TC_PROP:BRW(?List2,TCPROP:Rows,?List2{PROP:Items})    !  Reset number of rows property
  284.           TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)    !  Tell Browse to start redisplay with a search by key
  285.           TC_PROP:BRW(?List2,TCPROP:SetToPosition,2)            !  Set Redisplay at Key Position in Queue
  286.           DO BrowseList:BrowseQueue2                            !  Call BrowseList and Execute Redisplay
  287.         END                                                     !End
  288.       END                                    
  289.     OF ?Close                              
  290.       CASE EVENT()                           
  291.       OF EVENT:Accepted                 
  292.         LocalResponse = RequestCancelled
  293.         POST(Event:CloseWindow)
  294.       END                                    
  295.     OF ?Search                              
  296.       CASE EVENT()                           
  297.       OF EVENT:Accepted                 
  298.         DO EntrySearch:BrowseQueue1
  299.       END                                    
  300.     OF ?Search2                              
  301.       CASE EVENT()                           
  302.       OF EVENT:Accepted                 
  303.         DO EntrySearch:BrowseQueue2
  304.       END                                    
  305.     OF ?Insert                              
  306.       CASE EVENT()                           
  307.       OF EVENT:Accepted                 
  308.         POST(TCEVENT:InsertRecord,TC:BRW:ActiveList)            !Send Insert Message to List Box
  309.       END                                    
  310.     OF ?Change                              
  311.       CASE EVENT()                           
  312.       OF EVENT:Accepted                 
  313.         POST(TCEVENT:ChangeRecord,TC:BRW:ActiveList)            !Send Change Message to List Box
  314.       END                                    
  315.     OF ?Delete                              
  316.       CASE EVENT()                           
  317.       OF EVENT:Accepted                 
  318.         POST(TCEVENT:DeleteRecord,TC:BRW:ActiveList)            !Send Delete Message to List Box
  319.          CASE TC:BRW:ActiveList                            !For the Currently Active List
  320.          OF ?List1                                         !On List 1 (Template Instance 1)
  321.            IF RECORDS(MarkQueue) OR MarkAllFlag            !If Records are Marked
  322.                                                            !  Confirm Delete of Marked
  323.              Confirm# = MESSAGE('Delete ALL MARKED Recipes?',,|              
  324.                                  ICON:Question,Button:Yes+Button:No,|
  325.                                  Button:Yes,0)
  326.              IF Confirm# = Button:No OR KEYCODE() = EscKey !  If Not Confirmed 
  327.                CYCLE                                       !    Don't Delete
  328.              END                                           !  End IF
  329.                                                            !
  330.              SETCURSOR(CURSOR:Wait)                        !  Show Hour-Glass Cursor
  331.              IF MarkAllFlag                                !  If All Records Marked
  332.                SET(RCP:Key_RecipeNo)                       !    Process Entire File
  333.                LOOP UNTIL EOF(Recipe)                      !    Read and Delete all Records
  334.                  NEXT(Recipe)                              !      that are NOT in MarkQueue
  335.                  MQ1:RecipeNo = RCP:RecipeNo               !
  336.                  GET(MarkQueue,MQ1:RecipeNo)               !
  337.                  IF NOT ERROR() THEN CYCLE.                !
  338.                  Err# = RIDelete:Recipe()                  !
  339.                END                                         !
  340.              ELSE                                          !  Otherwise
  341.                LOOP Rec# = 1 TO RECORDS(MarkQueue)         !    Read and Delete Only Records
  342.                  GET(MarkQueue,Rec#)                       !      that ARE FOUND in MarkQueue
  343.                  RCP:RecipeNo = MQ1:RecipeNo               !
  344.                  GET(Recipe,RCP:Key_RecipeNo)              !
  345.                  IF ERROR() THEN CYCLE.                    !
  346.                  Err# = RIDelete:Recipe()                  !
  347.                END                                         !
  348.              END                                           !  End If All Records Marked
  349.              FREE(MarkQueue)                               !
  350.              CLEAR(MarkAllFlag)                            !
  351.              SETCURSOR(CURSOR:Arrow)                       !  Restore Normal Windows Cursor
  352.              POST(EVENT:ScrollTop,?List1)                  !  Redisplay Page
  353.              CYCLE                                         !
  354.            END                                             !End If Records Are Marked
  355.          END                                               !
  356.       END                                    
  357.     END                                                         !End Events for Controls
  358.   END                                                           !End Event Loop
  359.                                                                 !
  360.   DO ProcedureReturn                                            !Cleanup and Exit the Procedure
  361.  
  362.  
  363. !--------------------------------------------------------------------------------------------------!
  364. ! InitializeWindow Routine                                                                         !
  365. !                                                                                                  !
  366. ! Initialize and Display window for the first time.                                                !
  367. !--------------------------------------------------------------------------------------------------!
  368. InitializeWindow   ROUTINE
  369.   DO RefreshWindow
  370.  
  371.  
  372. !--------------------------------------------------------------------------------------------------!
  373. ! RefreshWindow Routine                                                                            !
  374. !                                                                                                  !
  375. ! Redisplays the fields for the window.                                                            !
  376. !--------------------------------------------------------------------------------------------------!
  377. RefreshWindow      ROUTINE
  378.  
  379.   IF Screen{Prop:AcceptAll} THEN EXIT.
  380.   TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)
  381.   TC_PROP:BRW(?List1,TCPROP:SetToItem,CHOICE(?List1))
  382.   TC_PROP:BRW(?List1,TCPROP:DontSelect,True)
  383.   DO BrowseList:BrowseQueue1
  384.   DISPLAY()
  385.   ForceRefresh = False
  386.  
  387.  
  388.  
  389.  
  390.  
  391. !--------------------------------------------------------------------------------------------------!
  392. ! ResizeWindow Routine                                                                             !
  393. !                                                                                                  !
  394. ! Resize the Window and Redsiplay any list boxes that were resized.Resized List Boxes              !
  395. !--------------------------------------------------------------------------------------------------!
  396. ResizeWindow       ROUTINE
  397.  
  398.   IF WinWidth = Screen{PROP:Width} AND |                        !If Window Width was not Changed AND
  399.      WinHeight = Screen{PROP:Height}                            !   Window Height was not Changed
  400.     EXIT                                                        !  Resize Not Needed - Exit Routine
  401.   END                                                           !End If
  402.                                                                 !
  403.   TC_ResizeWin(?List1,WinWidth,WinHeight,?List2)                !Reset Window Size
  404.   WinWidth = Screen{PROP:Width}                                 !Save Current Window Width
  405.   WinHeight = Screen{PROP:Height}                               !Save Current Window Height
  406.                                                                       !
  407.   IF NOT WindowInitialized THEN EXIT.                           !Refresh not needed if window not Init.
  408.                                                                 !
  409.   TC_PROP:BRW(?List2,TCPROP:Rows,?List2{PROP:Items})            !Reset Number of Rows in List Box
  410.   TC_PROP:BRW(?List2,TCPROP:SetToPosition,3)                    !Set for Redisplay at Key Position
  411.   TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)            !Tell Browse to Redisplay
  412.   DO BrowseList:BrowseQueue2                                    !Fill Browse Area
  413.                                                                 !
  414.   TC_PROP:BRW(?List1,TCPROP:Rows,?List1{PROP:Items})            !Reset Number of Rows in List Box
  415.   TC_PROP:BRW(?List1,TCPROP:SetToPosition,3)                    !Set for Redisplay at Key Position
  416.   TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)            !Tell Browse to Redisplay
  417.   DO BrowseList:BrowseQueue1                                    !Fill Browse Area
  418.                                                                 !
  419.   IF CurrentSelected THEN SELECT(CurrentSelected).              !Reslect Current Field
  420.  
  421.  
  422.  
  423. !--------------------------------------------------------------------------------------------------!
  424. ! BrowseList:BrowseQueue1 Routine                                                                  !
  425. !                                                                                                  !
  426. ! This routine calls the browser to do a page-loaded display from a file.                          !
  427. !--------------------------------------------------------------------------------------------------!
  428. BrowseList:BrowseQueue1 ROUTINE
  429.  
  430.   IF NOT TC_PROP:BRW(?List1,TCPROP:Initialized)                 !If Browse Not Initialized
  431.     IF NOT TC_InitBrowse(?List1,THREAD()) THEN EXIT.            !  Initialize Browse Processing for List Box
  432.     IF LocalRequest = SelectRecord                              !  If Browse Procedure Called as a Lookup
  433.       TC_PROP:BRW(?List1,TCPROP:SetToPosition,1)                !    Start Lookup on Current Record
  434.       TC_PROP:BRW(?List1,TCPROP:SelectRecord,True)              !    Set Double Click to Select Record
  435.     END                                                         !  End If
  436.   END                                                           !End If
  437.                                                                 !
  438.   LOOP                                                          !Process File Browse Loop
  439.     CASE SQ1:SortOrder                                          !Browse for Current Sort Order
  440.     OF 1                                                        !Sort Order Is By Name
  441.       TC_Browse(?List1               ,|                         !  Browse Handle
  442.                 RECIPE               ,|                         !  File Name
  443.                 RCP:RECORD           ,|                         !  Record Area
  444.                 RCP:Key_Name         ,|                         !  Key Order for Display
  445.                 BrowseQueue1         ,|                         !  Queue Name for List
  446.                 BrowseQueue1:Position )                         !  Record Position in Key Order
  447.     OF 2                                                        !Sort Order Is Beef Dishes Only
  448.       TC_Browse(?List1               ,|                         !  Browse Handle
  449.                 RECIPE               ,|                         !  File Name
  450.                 RCP:RECORD           ,|                         !  Record Area
  451.                 RCP:Key_Name         ,|                         !  Key Order for Display
  452.                 BrowseQueue1         ,|                         !  Queue Name for List
  453.                 BrowseQueue1:Position )                         !  Record Position in Key Order
  454.     OF 3                                                        !Sort Order Is Chicken Dishes Only
  455.       TC_Browse(?List1               ,|                         !  Browse Handle
  456.                 RECIPE               ,|                         !  File Name
  457.                 RCP:RECORD           ,|                         !  Record Area
  458.                 RCP:Key_Name         ,|                         !  Key Order for Display
  459.                 BrowseQueue1         ,|                         !  Queue Name for List
  460.                 BrowseQueue1:Position )                         !  Record Position in Key Order
  461.     END                                                         !End Case On Sort Orders
  462.  
  463.     CASE TC_PROP:BRW(?List1,TCPROP:Action)                      !Process Browse Actions
  464.     OF TCACTION:FillQueue                                       !Fill List Queue Action
  465.       CASE SQ1:SortOrder                                        !Filter for Current Sort Order
  466.       OF 2                                                      !Check Filter Condition
  467.         IF NOT(INSTRING('BEEF',UPPER(RCP:Name),1))              !  If Filter Condition Not Met
  468.           TC_PROP:BRW(?List1,TCPROP:SkipRecord,1)               !    Tell Browse to Skip Record
  469.           CYCLE                                                 !    No need to fill the Queue
  470.         END                                                     !  End If
  471.       OF 3                                                      !Check Filter Condition
  472.         IF NOT(INSTRING('CHICKEN',UPPER(RCP:Name),1))           !  If Filter Condition Not Met
  473.           TC_PROP:BRW(?List1,TCPROP:SkipRecord,1)               !    Tell Browse to Skip Record
  474.           CYCLE                                                 !    No need to fill the Queue
  475.         END                                                     !  End If
  476.       END                                                       !End Case
  477.       MQ1:RecipeNo = RCP:RecipeNo                               !  Prepare to Search for Marked Record
  478.       GET(MarkQueue,MQ1:RecipeNo)                               !  See if Record is Marked
  479.       IF (NOT MarkAllFlag AND NOT ERROR()) OR |                 !  If Record is Marked
  480.           (MarkAllFlag AND ERROR())                             !
  481.         MarkStatus = 'Marked'                                   !    Show Record as Marked
  482.       ELSE                                                      !  Otherwise
  483.         MarkStatus = 'UnMarked'                                 !    Show Record as Not Marked
  484.       END                                                       !  End If
  485.       BrowseQueue1:MarkStatus = MarkStatus                      !  Move Data to Queue
  486.       BrowseQueue1:RCP:Code = RCP:Code                          !  Move Data to Queue
  487.       BrowseQueue1:RCP:Name = RCP:Name                          !  Move Data to Queue
  488.       BrowseQueue1:RCP:RecipeNo = RCP:RecipeNo                  !  Move Data to Queue
  489.                                                                 !
  490.     OF TCACTION:InsertRecord                                    !Insert Record Action
  491.       GET(RECIPE,0)                                             !  Clear Pending Record
  492.       CLEAR(RCP:RECORD)                                         !  Clear Record Area
  493.       GlobalRequest = InsertRecord                              !  Tell Form To Insert Record
  494.       UpdateRecipe                                              !  Insert Record
  495.       IF GlobalResponse = RequestCompleted                      !  If Record Added
  496.         TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)      !    Tell Browse to Redisplay
  497.         TC_PROP:BRW(?List1,TCPROP:SetToPosition,1)              !    Record at Current Key Positon
  498.       END                                                       !  End If
  499.                                                                 !
  500.     OF TCACTION:ChangeRecord                                    !Change Record Action
  501.       GlobalRequest = ChangeRecord                              !  Tell Form To Change Record
  502.       UpdateRecipe                                              !  Change Record
  503.       IF GlobalResponse = RequestCompleted                      !  If Record Added
  504.         TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)      !    Tell Browse to Redisplay
  505.         TC_PROP:BRW(?List1,TCPROP:SetToPosition,1)              !    Record at the Current Key Positon
  506.       END                                                       !  End If
  507.                                                                 !
  508.     OF TCACTION:DeleteRecord                                    !Delete Record Action
  509.       GlobalRequest = DeleteRecord                              !  Tell Form To Delete Record
  510.       UpdateRecipe                                              !  Delete Record
  511.       IF GlobalResponse = RequestCompleted                      !  If Record Deleted
  512.         TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)      !    Tell Browse to Redisplay
  513.         TC_PROP:BRW(?List1,TCPROP:SetToItem,True)               !    Record at the Current Item
  514.       END                                                       !  End If
  515.                                                                 !
  516.     OF TCACTION:SelectRecord                                    !Select Record Action
  517.       LocalResponse = RequestCompleted                          !  Lookup was completed
  518.       POST(Event:CloseWindow)                                   !  Return Selected Record to Caller
  519.                                                                 !
  520.     OF TCACTION:DisplayFields                                   !Display Fields Action
  521.       IF TC_PROP:BRW(?List2,TCPROP:Initialized)                 !  If Browse is Initialized
  522.         TC_PROP:BRW(?List2,TCPROP:Action,0)                     !    Tell Browse to Redisplay
  523.         TC_PROP:BRW(?List2,TCPROP:DontSelect,1)                 !    Tell Browse not to Select the List Box
  524.       END                                                       !  End If
  525.       DO BrowseList:BrowseQueue2                                !  Call Browse Routine for the List Box
  526.       TC:BRW:ActiveList = ?List1                                !  Reset List Box as Being Active
  527.       DISPLAY()                                                 !  Display All Fields
  528.       IF RECORDS(BrowseQueue1)                                  !  If Records Displayed
  529.         ENABLE(?List2)                                          !    Enable Child List Box
  530.         ENABLE(?Mark)                                           !    Enable the Mark Button
  531.         ENABLE(?Unmark)                                         !    Enable the Unmark Button
  532.         ENABLE(?MarkAll)                                        !    Enable the Mark All Button
  533.         ENABLE(?UnmarkAll)                                      !    Enable the Unmark All Button
  534.         ENABLE(?Change)                                         !    Enable Change Button
  535.         ENABLE(?Delete)                                         !    Enable Delete Button
  536.       ELSE                                                      !  Else
  537.         DISABLE(?List2)                                         !    Disable Child List Box
  538.         DISABLE(?Mark)                                          !    Disable the Mark Button
  539.         DISABLE(?Unmark)                                        !    Disable the Unmark Button
  540.         DISABLE(?MarkAll)                                       !    Disable the Mark All Button
  541.         DISABLE(?UnmarkAll)                                     !    Disable the Unmark All Button
  542.         DISABLE(?Change)                                        !    Disable Change Button
  543.         DISABLE(?Delete)                                        !    Disable Delete Button
  544.       END                                                       !  End If
  545.                                                                 !
  546.     OF TCACTION:ExitBrowse                                      !Exit Browse Action
  547.       BREAK                                                     !
  548.     END                                                         !End Process Browse Actions
  549.   END                                                           !End Process File Browse Loop
  550.  
  551.  
  552.  
  553. !--------------------------------------------------------------------------------------------------!
  554. ! EntrySearch:BrowseQueue1 Routine                                                                 !
  555. !                                                                                                  !
  556. ! This routine processes a Entry search for ?List1                                                 !
  557. !--------------------------------------------------------------------------------------------------!
  558. EntrySearch:BrowseQueue1 ROUTINE
  559.  
  560.   CASE SQ1:SortOrder                                            !Setup Search for Current Sort Order
  561.   OF 1                                                          !For Current Sort Order
  562.     RCP:Name = Search                                           !  Fill Search Key
  563.   OF 2                                                          !For Current Sort Order
  564.     RCP:Name = Search                                           !  Fill Search Key
  565.   OF 3                                                          !For Current Sort Order
  566.     RCP:Name = Search                                           !  Fill Search Key
  567.   ELSE                                                          !Otherwise if not using a entry locator
  568.     EXIT                                                        !  Exit Routine
  569.   END                                                           !End Case
  570.  
  571.   Search = ''                                                   !Clear Search Input Field
  572.   DISPLAY(?Search)                                              !
  573.   TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)            !Tell Browse to Redisplay
  574.   TC_PROP:BRW(?List1,TCPROP:SetToKey,True)                      !Redisplay after searching by key
  575.   SELECT(?List1)                                                !Reselect Main List Box
  576.  
  577.  
  578.  
  579. !--------------------------------------------------------------------------------------------------!
  580. ! StepSearch:BrowseQueue1 Routine                                                                  !
  581. !                                                                                                  !
  582. ! This routine processes a step search for ?List1                                                  !
  583. !--------------------------------------------------------------------------------------------------!
  584. StepSearch:BrowseQueue1 ROUTINE
  585.  
  586.   IF INRANGE(KEYCODE(),KeyPad0,KeyPad9)                         !If Key is a numeric keypad key
  587.     SETKEYCODE(KEYCODE()-48)                                    !  Convert to regular numeric key
  588.   END                                                           !End If
  589.   IF (INRANGE(KEYCODE(),Key0,ZKey) OR |                         !If Key is a lower case 0-Z Key
  590.       INRANGE(KEYCODE(),Shift0,ShiftZ))                         !   or it's a upper case 0-Z Key
  591.     CASE SQ1:SortOrder                                          !  Setup Locator for Current Sort Order
  592.     OF 1                                                        !  For Sort Orders Not Using Incremental Search
  593.       RCP:Name = CHR(KEYCODE())                                 !    Move character into locator
  594.     OF 2                                                        !  For Sort Orders Not Using Incremental Search
  595.       RCP:Name = CHR(KEYCODE())                                 !    Move character into locator
  596.     OF 3                                                        !  For Sort Orders Not Using Incremental Search
  597.       RCP:Name = CHR(KEYCODE())                                 !    Move character into locator
  598.     END                                                         !  End Case
  599.     TC_PROP:BRW(?List1,TCPROP:Action,TCACTION:Refresh)          !  Tell Browse to Redisplay
  600.     TC_PROP:BRW(?List1,TCPROP:SetToKey,True)                    !  Redisplay after searching by key
  601.   END                                                           !End If
  602.  
  603.  
  604.  
  605. !--------------------------------------------------------------------------------------------------!
  606. ! LoadSortOrders:BrowseQueue1 Routine                                                              !
  607. !                                                                                                  !
  608. ! This routine loads the available sort options into the DropBoxOrderQ                             !
  609. !--------------------------------------------------------------------------------------------------!
  610. LoadSortOrders:BrowseQueue1 ROUTINE
  611.  
  612.   FREE(DropBoxOrderQ)                                           !Make sure queue is empty
  613.  
  614.   SQ1:SearchPicture = '@S20'                                    !Set Picture for Search Field
  615.   SQ1:OrderName = 'By Name'                                     !Set Name of Sort Order
  616.   SQ1:OrderFormat = FORMAT:BrowseQueue1:Default                 !Set Format String for Sort Order
  617.   ADD(DropBoxOrderQ)                                            !Add the option
  618.  
  619.   SQ1:SearchPicture = '@S20'                                    !Set Picture for Search Field
  620.   SQ1:OrderName = 'Beef Dishes Only'                            !Set Name of Sort Order
  621.   SQ1:OrderFormat = FORMAT:BrowseQueue1:Default                 !Set Format String for Sort Order
  622.   ADD(DropBoxOrderQ)                                            !Add the option
  623.  
  624.   SQ1:SearchPicture = '@S20'                                    !Set Picture for Search Field
  625.   SQ1:OrderName = 'Chicken Dishes Only'                         !Set Name of Sort Order
  626.   SQ1:OrderFormat = FORMAT:BrowseQueue1:Default                 !Set Format String for Sort Order
  627.   ADD(DropBoxOrderQ)                                            !Add the option
  628.  
  629.   SQ1:SortOrder = 1                                             !Default to Sort Order #1
  630.   GET(DropBoxOrderQ,SQ1:SortOrder)                              !Get Sort Order Entry from Queue
  631.   SELECT(?ChangeOrder,SQ1:SortOrder)                            !Set Initial Sort Order for Drop Box
  632.   ?Search{PROP:Text} = SQ1:SearchPicture                        !Set Initial Picture for Search Field
  633.   ?List1{PROP:Format} = SQ1:OrderFormat                         !Set Initial Format for List Box
  634.  
  635.  
  636.  
  637. !--------------------------------------------------------------------------------------------------!
  638. ! BrowseList:BrowseQueue2 Routine                                                                  !
  639. !                                                                                                  !
  640. ! This routine calls the browser to do a page-loaded display from a file.                          !
  641. !--------------------------------------------------------------------------------------------------!
  642. BrowseList:BrowseQueue2 ROUTINE
  643.  
  644.   IF NOT TC_PROP:BRW(?List2,TCPROP:Initialized)                 !If Browse Not Initialized
  645.     IF NOT TC_InitBrowse(?List2,THREAD()) THEN EXIT.            !  Initialize Browse Processing for List Box
  646.     TC_PROP:BRW(?List2,TCPROP:InsertMode,1)                     !  Set Insert Mode to Top of List
  647.     TC_PROP:BRW(?List2,TCPROP:DontSelect,1)                     !  Tell Browse not to Select the List Box
  648.     IF LocalRequest = SelectRecord                              !  If Browse Procedure Called as a Lookup
  649.       TC_PROP:BRW(?List2,TCPROP:SetToPosition,1)                !    Start Lookup on Current Record
  650.       TC_PROP:BRW(?List2,TCPROP:SelectRecord,True)              !    Set Double Click to Select Record
  651.     END                                                         !  End If
  652.   END                                                           !End If
  653.                                                                 !
  654.   LOOP                                                          !Process File Browse Loop
  655.     CASE SQ7:SortOrder                                          !Browse for Current Sort Order
  656.     OF 1                                                        !Sort Order Is By Ingredient
  657.       TC_Browse(?List2               ,|                         !  Browse Handle
  658.                 INGREDIENT           ,|                         !  File Name
  659.                 ING:RECORD           ,|                         !  Record Area
  660.                 ING:Key_Ingredient   ,|                         !  Key Order for Display
  661.                 BrowseQueue2         ,|                         !  Queue Name for List
  662.                 BrowseQueue2:Position ,|                        !  Record Position in Key Order
  663.                 ING:RecipeNo         ,|                         !  Range Field
  664.                 RCP:RecipeNo         ,|                         !  Match Range - Low Value
  665.                 RCP:RecipeNo         )                          !  Match Range - High Value
  666.     OF 2                                                        !Sort Order Is By Measure
  667.       TC_Browse(?List2               ,|                         !  Browse Handle
  668.                 INGREDIENT           ,|                         !  File Name
  669.                 ING:RECORD           ,|                         !  Record Area
  670.                 ING:Key_Measure      ,|                         !  Key Order for Display
  671.                 BrowseQueue2         ,|                         !  Queue Name for List
  672.                 BrowseQueue2:Position ,|                        !  Record Position in Key Order
  673.                 ING:RecipeNo         ,|                         !  Range Field
  674.                 RCP:RecipeNo         ,|                         !  Match Range - Low Value
  675.                 RCP:RecipeNo         )                          !  Match Range - High Value
  676.     END                                                         !End Case On Sort Orders
  677.  
  678.     CASE TC_PROP:BRW(?List2,TCPROP:Action)                      !Process Browse Actions
  679.     OF TCACTION:FillQueue                                       !Fill List Queue Action
  680.       MQ1:RecipeNo = RCP:RecipeNo                               !  Prepare to Search for Marked Record
  681.       GET(MarkQueue,MQ1:RecipeNo)                               !  See if Record is Marked
  682.       IF (NOT MarkAllFlag AND NOT ERROR()) OR |                 !  If Record is Marked
  683.           (MarkAllFlag AND ERROR())                             !
  684.         MarkStatus = 'Marked'                                   !    Show Record as Marked
  685.       ELSE                                                      !  Otherwise
  686.         MarkStatus = 'UnMarked'                                 !    Show Record as Not Marked
  687.       END                                                       !  End If
  688.       BrowseQueue2:ING:Ingredient = ING:Ingredient              !  Move Data to Queue
  689.       BrowseQueue2:ING:Measure = ING:Measure                    !  Move Data to Queue
  690.       BrowseQueue2:ING:Quantity = ING:Quantity                  !  Move Data to Queue
  691.                                                                 !
  692.     OF TCACTION:InsertRecord                                    !Insert Record Action
  693.       GET(INGREDIENT,0)                                         !  Clear Pending Record
  694.       CLEAR(ING:RECORD)                                         !  Clear Record Area
  695.       DISABLE(?ChangeOrder2)                                    !  Disable Change Order Control
  696.       BrowseIntermediate:Update:BrowseQueue2(?List2,TCACTION:InsertRecord,SQ7:SortOrder) !  Call In-Line Update Procedure
  697.       ENABLE(?ChangeOrder2)                                     !  Enable Change Order Control
  698.       IF GlobalResponse = RequestCompleted                      !  If Update Completed
  699.         TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)      !    Tell Browse to Redisplay
  700.         TC_PROP:BRW(?List2,TCPROP:SetToPosition,2)              !    Record at the current positon
  701.       ELSE                                                      !  Otherwise
  702.         DELETE(BrowseQueue2)                                    !    Delete Cancelled Queue Record
  703.         POST(EVENT:ScrollTop,?List2)                            !    Redisplay First Page of Records
  704.       END                                                       !  End If
  705.                                                                 !
  706.     OF TCACTION:ChangeRecord                                    !Change Record Action
  707.       DISABLE(?ChangeOrder2)                                    !  Disable Change Order Control
  708.       BrowseIntermediate:Update:BrowseQueue2(?List2,TCACTION:ChangeRecord,SQ7:SortOrder) !  Call In-Line Update Procedure
  709.       ENABLE(?ChangeOrder2)                                     !  Enable Change Order Control
  710.       TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)        !  Tell Browse to Redisplay
  711.       TC_PROP:BRW(?List2,TCPROP:SetToPosition,2)                !  Record at the current positon
  712.                                                                 !
  713.     OF TCACTION:DeleteRecord                                    !Delete Record Action
  714.       DISABLE(?ChangeOrder2)                                    !  Disable Change Order Control
  715.       BrowseIntermediate:Update:BrowseQueue2(?List2,TCACTION:DeleteRecord,SQ7:SortOrder) !  Call In-Line Update Procedure
  716.       ENABLE(?ChangeOrder2)                                     !  Enable Change Order Control
  717.       TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)        !  Tell Browse to Redisplay
  718.       TC_PROP:BRW(?List2,TCPROP:SetToItem,True)                 !  Record at the current positon
  719.                                                                 !
  720.     OF TCACTION:SelectRecord                                    !Select Record Action
  721.       LocalResponse = RequestCompleted                          !  Lookup was completed
  722.       POST(Event:CloseWindow)                                   !  Return Selected Record to Caller
  723.                                                                 !
  724.     OF TCACTION:DisplayFields                                   !Display Fields Action
  725.       DISPLAY()                                                 !  Display All Fields
  726.                                                                 !
  727.     OF TCACTION:ExitBrowse                                      !Exit Browse Action
  728.       BREAK                                                     !
  729.     END                                                         !End Process Browse Actions
  730.   END                                                           !End Process File Browse Loop
  731.  
  732.  
  733.  
  734. !--------------------------------------------------------------------------------------------------!
  735. ! EntrySearch:BrowseQueue2 Routine                                                                 !
  736. !                                                                                                  !
  737. ! This routine processes a Entry search for ?List2                                                 !
  738. !--------------------------------------------------------------------------------------------------!
  739. EntrySearch:BrowseQueue2 ROUTINE
  740.  
  741.   CASE SQ7:SortOrder                                            !Setup Search for Current Sort Order
  742.   OF 1                                                          !For Current Sort Order
  743.     ING:Ingredient = Search2                                    !  Fill Search Key
  744.   OF 2                                                          !For Current Sort Order
  745.     ING:Measure = Search2                                       !  Fill Search Key
  746.   ELSE                                                          !Otherwise if not using a entry locator
  747.     EXIT                                                        !  Exit Routine
  748.   END                                                           !End Case
  749.  
  750.   LocLen:BrowseQueue2 = 0                                       !Clear Locator Length
  751.   Search2 = ''                                                  !Clear Search Input Field
  752.   DISPLAY(?Search2)                                             !
  753.   TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)            !Tell Browse to Redisplay
  754.   TC_PROP:BRW(?List2,TCPROP:SetToKey,True)                      !Redisplay after searching by key
  755.   SELECT(?List2)                                                !Reselect Main List Box
  756.  
  757.  
  758.  
  759. !--------------------------------------------------------------------------------------------------!
  760. ! StepSearch:BrowseQueue2 Routine                                                                  !
  761. !                                                                                                  !
  762. ! This routine processes a step search for ?List2                                                  !
  763. !--------------------------------------------------------------------------------------------------!
  764. StepSearch:BrowseQueue2 ROUTINE
  765.  
  766.   CASE SQ7:SortOrder                                            !Setup Search for Current Sort Order
  767.   OF 1                                                          !For Sort Orders Not Using Step Search
  768.     EXIT                                                        !  Exit Routine
  769.   END                                                           !End Case
  770.   
  771.   IF INRANGE(KEYCODE(),KeyPad0,KeyPad9)                         !If Key is a numeric keypad key
  772.     SETKEYCODE(KEYCODE()-48)                                    !  Convert to regular numeric key
  773.   END                                                           !End If
  774.   IF (INRANGE(KEYCODE(),Key0,ZKey) OR |                         !If Key is a lower case 0-Z Key
  775.       INRANGE(KEYCODE(),Shift0,ShiftZ))                         !   or it's a upper case 0-Z Key
  776.     CASE SQ7:SortOrder                                          !  Setup Locator for Current Sort Order
  777.     OF 2                                                        !  For Sort Orders Not Using Incremental Search
  778.       ING:Measure = CHR(KEYCODE())                              !    Move character into locator
  779.     END                                                         !  End Case
  780.     TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)          !  Tell Browse to Redisplay
  781.     TC_PROP:BRW(?List2,TCPROP:SetToKey,True)                    !  Redisplay after searching by key
  782.   END                                                           !End If
  783.  
  784.  
  785.  
  786. !--------------------------------------------------------------------------------------------------!
  787. ! IncrementalSearch:BrowseQueue2 Routine                                                           !
  788. !                                                                                                  !
  789. ! This routine processes a incremental search for ?List2                                           !
  790. !--------------------------------------------------------------------------------------------------!
  791. IncrementalSearch:BrowseQueue2 ROUTINE
  792.  
  793.   CASE SQ7:SortOrder                                            !Setup Search for Current Sort Order
  794.   OF 2                                                          !For Sort Orders Not Using Incremental Search
  795.     EXIT                                                        !  Exit Routine
  796.   END                                                           !End Case
  797.   
  798.   IF INRANGE(KEYCODE(),KeyPad0,KeyPad9)                         !If Key is a numeric keypad key
  799.     SETKEYCODE(KEYCODE()-48)                                    !  Convert to regular numeric key
  800.   END                                                           !End If
  801.   IF (INRANGE(KEYCODE(),Key0,ZKey) OR |                         !If Key is a lower case 0-Z Key
  802.       INRANGE(KEYCODE(),187,192) OR |                           !   or other usable characters
  803.       INRANGE(KEYCODE(),Shift0,ShiftZ) OR |                     !   or it's a upper case 0-Z Key
  804.       KEYCODE() = BSKey OR KEYCODE() = SpaceKey)                !   or it's the BackSpace or Space Key
  805.     IF KEYCODE() = BSKey                                        !  If BackSpace Key Pressed
  806.       IF LocLen:BrowseQueue2                                    !    If Not First Position in Locator
  807.         LocLen:BrowseQueue2 -= 1                                !      Substract 1 from Length
  808.         Search2 = SUB(Search2,1,LocLen:BrowseQueue2)            !      Remove Last Character from Search
  809.       END                                                       !    End If
  810.     ELSIF KEYCODE() = SpaceKey                                  !  If BackSpace Key Pressed
  811.       IF LocLen:BrowseQueue2 < LEN(Search2)                     !    If Not Last Position in Locator
  812.         LocLen:BrowseQueue2 += 1                                !      Add 1 to Length
  813.       END                                                       !    End If
  814.     ELSE
  815.       IF LocLen:BrowseQueue2 < LEN(Search2)                     !    If Not Last Position in Locator
  816.         Search2 = SUB(Search2,1,LocLen:BrowseQueue2) & CHR(KEYCHAR()) !  Add Character to Search
  817.         LocLen:BrowseQueue2 += 1                                !      Add 1 to Length
  818.       END                                                       !    End if
  819.     END                                                         !  End
  820.     CASE SQ7:SortOrder                                          !  Setup Locator for Current Sort Order
  821.     OF 1                                                        !  For Sort Orders Not Using Incremental Search
  822.       ING:Ingredient = Search2                                  !    Fill Search Key
  823.     END                                                         !  End Case
  824.     TC_PROP:BRW(?List2,TCPROP:Action,TCACTION:Refresh)          !  Tell Browse to Redisplay
  825.     TC_PROP:BRW(?List2,TCPROP:SetToKey,True)                    !  Redisplay after searching by key
  826.   ELSE                                                          !Else
  827.     LocLen:BrowseQueue2 = 0                                     !  Clear Locator Length
  828.     Search2 = ''                                                !  Clear the Search Input Field
  829.   END                                                           !End If
  830.   DISPLAY(?Search2)                                             !Display Locator Field
  831.  
  832.  
  833.  
  834. !--------------------------------------------------------------------------------------------------!
  835. ! LoadSortOrders:BrowseQueue2 Routine                                                              !
  836. !                                                                                                  !
  837. ! This routine loads the available sort options into the OptBoxOrderQ:BrowseQueue2                 !
  838. !--------------------------------------------------------------------------------------------------!
  839. LoadSortOrders:BrowseQueue2 ROUTINE
  840.  
  841.   FREE(OptBoxOrderQ:BrowseQueue2)                               !Make sure queue is empty
  842.  
  843.   SQ7:SearchPicture = '@S15'                                    !Set Picture for Search Field
  844.   SQ7:OrderName = 'By Ingredient'                               !Set Name of Sort Order
  845.   SQ7:OrderFormat = FORMAT:BrowseQueue2:Order1                  !Set Format String for Sort Order
  846.   ADD(OptBoxOrderQ:BrowseQueue2)                                !Add the option
  847.  
  848.   SQ7:SearchPicture = '@S8'                                     !Set Picture for Search Field
  849.   SQ7:OrderName = 'By Measure'                                  !Set Name of Sort Order
  850.   SQ7:OrderFormat = FORMAT:BrowseQueue2:Order2                  !Set Format String for Sort Order
  851.   ADD(OptBoxOrderQ:BrowseQueue2)                                !Add the option
  852.  
  853.   SQ7:SortOrder = 1                                             !Default to Sort Order #1
  854.   GET(OptBoxOrderQ:BrowseQueue2,SQ7:SortOrder)                  !Get Sort Order Entry from Queue
  855.   SELECT(?ChangeOrder2,SQ7:SortOrder)                           !Set Initial Sort Order for Drop Box
  856.   ?Search2{PROP:Text} = SQ7:SearchPicture                       !Set Initial Picture for Search Field
  857.   ?List2{PROP:Format} = SQ7:OrderFormat                         !Set Initial Format for List Box
  858.  
  859.  
  860.  
  861. !--------------------------------------------------------------------------------------------------!
  862. ! ProcedureReturn Routine                                                                                   !
  863. !                                                                                                  !
  864. ! End of procedure cleanup and exit.                                                               !
  865. !--------------------------------------------------------------------------------------------------!
  866. ProcedureReturn    ROUTINE
  867.  
  868.   INGREDIENT::Used -= 1
  869.   IF INGREDIENT::Used = 0 THEN CLOSE(INGREDIENT).
  870.   RECIPE::Used -= 1
  871.   IF RECIPE::Used = 0 THEN CLOSE(RECIPE).
  872.  
  873.   IF WindowOpened
  874.     INISaveWindow('BrowseIntermediate','PTDEMO.INI')
  875.     CLOSE(Screen)
  876.   END
  877.  
  878.   FREE(DropBoxOrderQ)                                           !Release Memory use by SortOrder Queue
  879.   FREE(BrowseQueue1)                                            !Release Memory use by Browse Queue
  880.   FREE(OptBoxOrderQ:BrowseQueue2)                               !Release Memory use by SortOrder Queue
  881.   FREE(BrowseQueue2)                                            !Release Memory use by Browse Queue
  882.   FREE(MarkQueue)                                               !Release Memory use by Mark Records Queue
  883.  
  884.   GlobalResponse = LocalResponse
  885.   RETURN
  886.  
  887.  
  888. !==================================================================================================!
  889. !                                                                                                  !
  890. ! BrowseIntermediate:Update:BrowseQueue2 Procedure                                                 !
  891. ! ------------------------------------                                                             !
  892. ! FILE NAME   : INGREDIENT                                                                         !
  893. ! LIST CONTROL: ?List2                                                                             !
  894. ! FROM QUEUE  : BrowseQueue2                                                                       !
  895. !                                                                                                  !
  896. !==================================================================================================!
  897. BrowseIntermediate:Update:BrowseQueue2 PROCEDURE(ListControl,UpdateAction,SortOrder,AbortButton,SaveButton)
  898.  
  899. FieldOrder1          EQUATE('1,2,3')                            !Field Order for Sort Order 1
  900. FieldOrder2          EQUATE('2,3,1')                            !Field Order for Sort Order 2
  901.  
  902. ?ING:Ingredient      EQUATE(101)                                !Set Field Number for ING:Ingredient
  903. ?ING:Measure         EQUATE(102)                                !Set Field Number for ING:Measure
  904. ?ING:Quantity        EQUATE(103)                                !Set Field Number for ING:Quantity
  905.  
  906. InLineFieldSetup     GROUP
  907.                        LONG(CREATE:Entry)                       !Control Type for ?ING:Ingredient
  908.                        LONG(CREATE:DropList)                    !Control Type for ?ING:Measure
  909.                        LONG(CREATE:Spin)                        !Control Type for ?ING:Quantity
  910.                      END
  911. InLineFields         LONG,DIM(3),OVER(InLineFieldSetup)
  912.  
  913. LocalResponse        LONG,AUTO
  914. SAVE:ING:RECORD      STRING(SIZE(ING:RECORD))
  915.  
  916.  
  917.  
  918.  
  919. !--------------------------------------------------------------------------------------------------!
  920. ! Code Section                                                                                     !
  921. !--------------------------------------------------------------------------------------------------!
  922.   CODE
  923.  
  924.   LocalResponse = RequestCancelled                              !Default to Request Cancelled
  925.   CASE UpdateAction                                             !Process Setup for Update Actions
  926.   OF TCACTION:InsertRecord                                      !On Insert New Record
  927.     ING:RecipeNo = RCP:RecipeNo
  928.     SAVE:ING:RECORD = ING:RECORD                                !  Save the Current Record
  929.     ING:Quantity = 1                                            !  Prime Field
  930.                                                                 !
  931.   OF TCACTION:ChangeRecord                                      !On Change Record
  932.     SAVE:ING:RECORD = ING:RECORD                                !  Save the Current Record
  933.                                                                 !
  934.   OF TCACTION:DeleteRecord                                      !On Delete Record
  935.     DO DeleteRecord                                             !  Delete the Record
  936.     GlobalResponse = LocalResponse                              !  Set Global Response
  937.     RETURN                                                      !  Exit Update Procedure
  938.   END                                                           !End Case
  939.                                                                 !
  940.   ListControl{PROP:NoBar} = 1                                   !Turn Off Point Bar
  941.                                                                 !
  942.   LOOP                                                          !Process InLine Actions
  943.     TC:INL:FirstField = ?ING:Ingredient                         !Set First Field Number
  944.     EXECUTE SortOrder                                           !Edit by Sort Order
  945.       TC_InLine(ListControl,InLineFields[],FieldOrder1)         !Call InLine Editing
  946.       TC_InLine(ListControl,InLineFields[],FieldOrder2)         !Call InLine Editing
  947.     END                                                         !End Execute
  948.                                                                 !
  949.     CASE TC:INL:Action                                          !Process InLine Actions
  950.     OF TCACTION:SetFields                                       !Set Field Properties Action
  951.       !--------- ?ING:Ingredient ---------
  952.       ?ING:Ingredient{PROP:Use} = ING:Ingredient
  953.       ?ING:Ingredient{PROP:Msg} = 'Enter an  Ingredient'
  954.  
  955.       !--------- ?ING:Measure ---------
  956.       ?ING:Measure{PROP:Use} = ING:Measure
  957.       ?ING:Measure{PROP:Msg} = 'Select a Measure'
  958.       ?ING:Measure{PROP:Drop} = 7  
  959.       ?ING:Measure{PROP:From} = 'cup|gallon|lb|ounce|pint|tsp'
  960.       ?ING:Measure{PROP:Format} = '32L@S8@'
  961.  
  962.       !--------- ?ING:Quantity ---------
  963.       ?ING:Quantity{PROP:Use} = ING:Quantity
  964.       ?ING:Quantity{PROP:Msg} = 'Select a Quantity'
  965.       ?ING:Quantity{PROP:RangeHigh} = 99
  966.       ?ING:Quantity{PROP:RangeLow} = 1
  967.       ?ING:Quantity{PROP:Step} = 1
  968.  
  969.     OF TCACTION:SetHotKeys                                      !Set Hot Keys Action
  970.       TC:INL:AbortKey = EscKey                                  !  Set Cancel Key
  971.       TC:INL:SaveKey = CtrlEnter                                !  Set Save Key
  972.     
  973.     OF TCACTION:FieldEdits                                      !Process Field Edits Action
  974.       CASE TC:INL:Field
  975.       OF ?ING:Measure
  976.         IF NOT ING:Measure
  977.           BEEP
  978.           TC:INL:AbortUpdate = ?ING:Measure
  979.         END
  980.       END
  981.     
  982.     OF TCACTION:UpdateRecord                                    !Update Record Action
  983.       IF SAVE:ING:RECORD = ING:RECORD                           !If the Record was Not Changed
  984.         LocalResponse = RequestCompleted                        !  Set Local Response to Completed
  985.         CYCLE                                                   !  Nothing to Save - Exit In-Line
  986.       END                                                       !End If
  987.       LOOP                                                      !Attempt to Update Until Done or Canceled
  988.         Error# = DUPLICATE(INGREDIENT)                          !  Test For Duplicate Key
  989.         IF Error#                                               !  If Duplicate Key Error
  990.           Button# = MESSAGE('Updating this record creates a duplicate entry!', |
  991.                             'Duplicate Key Error',ICON:Exclamation,Button:OK,Button:OK,0)
  992.         ELSE                                                    !  Otherwise
  993.           SETCURSOR(Cursor:Wait)                                !    Show Hour-Glass Cursor
  994.           IF UpdateAction = TCACTION:InsertRecord               !  If Inserting a New Record
  995.             ADD(INGREDIENT)                                     !    Add the Record
  996.             Error# = ERRORCODE()                                !    Set Error Flag
  997.           ELSE                                                  !  Otherwise on Updating a Record
  998.             Error# = RIUpdate:INGREDIENT()                      !    Attempt Update
  999.           END                                                   !  End If
  1000.         END                                                     !  End If
  1001.         IF Error#                                               !  If Error Updating
  1002.           SETCURSOR()                                           !    Reset to Normal Cursor
  1003.           Button# = StandardWarning(Warn:UpdateError)           !    Ask If User Wants to Try Saving Again
  1004.           DISPLAY                                               !    Refresh Screen
  1005.           CASE Button#                                          !    Process User Response
  1006.           OF Button:Yes                                         !    On YES Button
  1007.              CYCLE                                              !      Retry Update Operation
  1008.           OF Button:No                                          !    On NO Button
  1009.             BREAK                                               !      Exit without Updating Record
  1010.           OF Button:Cancel                                      !    On Cancel Button
  1011.             TC:INL:AbortUpdate = True                           !      Tell Inline to Cancel Update Request
  1012.             BREAK                                               !      Go back to editing record
  1013.           END                                                   !    End Case
  1014.         END                                                     !  End If
  1015.         SETCURSOR()                                             !  Reset to Normal Cursor
  1016.         LocalResponse = RequestCompleted                        !  Set Local Response to Completed
  1017.         BREAK                                                   !  Exit Update Loop
  1018.       END                                                       !End Loop
  1019.                                                                 !
  1020.     OF TCACTION:AbortUpdate                                     !Abort Update Action
  1021.       IF TC:INL:ResizeWindow THEN CYCLE.                        !Always abort changes on resize
  1022.       IF SAVE:ING:RECORD <> ING:RECORD                          !If the Record was Changed
  1023.         Button# = StandardWarning(Warn:SaveOnCancel)            !  Display Save on Cancel Message
  1024.         DISPLAY                                                 !  Refresh Screen
  1025.         CASE Button#                                            !  Process User Response
  1026.         OF Button:Yes                                           !  On YES Button
  1027.           TC:INL:AbortUpdate = False                            !    Cancel the Request to Abort
  1028.           TC:INL:SelectField = ListControl                      !    Select List to Exit & Save Changes
  1029.         OF Button:No                                            !  On NO Button
  1030.           TC:INL:AbortUpdate = True                             !    Go Ahead and Abandon the Changes
  1031.         OF BUTTON:Cancel                                        !  On Cancel Button
  1032.           TC:INL:AbortUpdate = False                            !    Cancel the Request and Continue
  1033.         END                                                     !  End Case
  1034.       END                                                       !End If
  1035.       IF UpdateAction = TCACTION:InsertRecord                   !If Adding a New Record
  1036.         IF TC:INL:AbortUpdate = True                            !  If Record Add was Aborted
  1037.           DELETE(INGREDIENT)                                    !    Delete the New Record from the File
  1038.         END                                                     !  End If
  1039.       END                                                       !End If
  1040.                                                                 !
  1041.     OF TCACTION:ExitInLine                                      !Exit InLine Action
  1042.       BREAK                                                     !
  1043.     END                                                         !End Case on Actions
  1044.   END                                                           !End Loop
  1045.                                                                 !
  1046.   GlobalResponse = LocalResponse                                !Set Global Response
  1047.   RETURN                                                        !Exit In-Line Update Procedure
  1048.  
  1049.  
  1050.  
  1051.  
  1052. !--------------------------------------------------------------------------------------------------!
  1053. ! Delete Record Routine                                                                            !
  1054. !                                                                                                  !
  1055. ! This routine Deletes the Record.                                                                 !
  1056. !--------------------------------------------------------------------------------------------------!
  1057. DeleteRecord         ROUTINE
  1058.  
  1059.   LocalResponse = RequestCancelled                              !Default to Request to Delete Cancelled
  1060.                                                                 !
  1061.   Confirm# = StandardWarning(Warn:StandardDelete)               !Get Confirmation from User
  1062.   DISPLAY                                                       !Refresh Screen
  1063.   IF Confirm# <> Button:OK THEN EXIT.                           !If User Did Not Confirm Delete then Exit
  1064.                                                                 !
  1065.   LOOP                                                          !Attempt to Delete Until Done or Canceled
  1066.     SETCURSOR(Cursor:Wait)                                      !  Show Hour-Glass Cursor
  1067.     IF RIDelete:INGREDIENT()                                    !  If Error Deleting
  1068.       SETCURSOR()                                               !    Reset to Normal Cursor
  1069.       CASE StandardWarning(Warn:DeleteError)                    !    Ask If User Wants to Try Deleting Again
  1070.       OF Button:Yes                                             !    On YES Button
  1071.         CYCLE                                                   !      Retry Delete Operation
  1072.       OF Button:No                                              !    On NO Button
  1073.       OROF Button:Cancel                                        !    Or On Cancel Button
  1074.         BREAK                                                   !      Exit without Deleting Record
  1075.       END                                                       !    End Case
  1076.     END                                                         !  End If
  1077.     SETCURSOR()                                                 !  Reset to Normal Cursor
  1078.     LocalResponse = RequestCompleted                            !  Set Request Completed
  1079.     BREAK                                                       !  Exit Delete Loop
  1080.   END                                                           !End Loop
  1081.  
  1082.  
  1083.  
  1084.  
  1085.